﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net;
using System.Threading;

[assembly: log4net.Config.XmlConfigurator(Watch = true)]
namespace WeChatDataSrc
{
    class Program
    {
        static void Main(string[] args)
        {
            
            DateTime? sd = null;
            try
            {
                string startDate = args[0];
                sd = DateTime.Parse(startDate);
            }
            catch
            {
                sd = null;
            }

            //sd = DateTime.Parse("2015-04-1");
            
            Upload(sd);
        }

        private static void Upload(DateTime? sd)
        {
            ILog Logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
            //string data = "";
            Console.WriteLine();
            Console.WriteLine("===================={0}===================\r\n", "正在上传实况数据");

            try
            {
                SceneData.UploadData(sd);
            }
            catch (Exception e)
            {
                Logger.Error("实况上传错误");
                Logger.Error(e);
            }

            Console.WriteLine("===================={0}===================\r\n", "正在上传全省文字报数据");

            try
            {
                ForecastMessage.UploadMsg(sd);
            }
            catch (Exception e)
            {
                Logger.Error("全省文字报上传错误");
                Logger.Error(e);
            }



            Console.WriteLine("===================={0}===================\r\n", "正在上传雷达图");

            try
            {
                RadarImage.UploadImage(sd);
            }
            catch (Exception e)
            {
                Logger.Error("雷达图上传错误");
                Logger.Error(e);
            }


            Console.WriteLine("===================={0}===================\r\n", "正在上传城镇报数据");

            try
            {
                CityForeData.UploadData(sd);
            }
            catch (Exception e)
            {
                Logger.Error("城镇报数据上传错误");
                Logger.Error(e);
            }

            Console.WriteLine("===================={0}===================\r\n", "正在上传日报数据");

            try
            {
                ForeCheckData.UploadData(sd);
            }
            catch (Exception e)
            {
                Logger.Error("日报数据上传错误");
                Logger.Error(e);
            }

            Console.WriteLine("===================={0}===================\r\n", "正在上传精细化预报数据(Detail_Fore)");

            try
            {
                RefineForeData.UploadData(sd);
            }
            catch (Exception e)
            {
                Logger.Error("精细化预报(Detail_Fore)上传错误");
                Logger.Error(e);
            }

            Console.WriteLine("===================={0}===================\r\n", "正在上传精细化预报数据(Minute_Fore)");

            try
            {
                MinutesForeData.UploadData(sd);
            }
            catch (Exception e)
            {
                Logger.Error("精细化预报(Minute_Fore)上传错误");
                Logger.Error(e);
            }


            Logger.Info("完成数据上传  " + DateTime.Now.ToString() + "\r\n\r\n");
            
            //Console.ReadKey();
        }
    }
}
